import axios from 'axios';
import { ElMessage } from 'element-plus';

export async function upload(formData : FormData) : Promise<string> {
    let baseUrl = import.meta.env.VITE_APP_BASE_API
    let url = baseUrl + "/oss/uploadImg"
    let method = "post"
    let headers = {
        'Accept': 'application/json',
        'Content-Type': 'multipart/form-data'
    }
    try {
        const res = await axios({ method, url, data: formData, headers });
        return res.data.data
    } catch (e) {
        ElMessage({
            message: e + '上传失败，请重试!',
            grouping: true,
            type: 'error',
        });
        return ""
    }
}
